home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / cmodglue / amiconsasc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-22  |  18.9 KB  |  813 lines

  1. #include <exec/exec.h>
  2. #include <dos/dos.h>
  3. #include <libraries/dos.h>
  4. #include <devices/timer.h>
  5. #include <intuition/intuitionbase.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include "sc:ae/CmodGlue/doorheader.h"
  9. #include <proto/exec.h>
  10. #include <proto/dos.h>
  11. #include <string.h>
  12. //#include <functions.h>
  13. #define FOREVER for(;;)
  14. #define SM sendmessage
  15. #define HK hotkey
  16. #define FHK Fhotkey
  17. #define PM prompt
  18. #define LI lineinput
  19. #define JH_CK 500
  20. #define JH_ExtHK 15
  21.  
  22.  
  23. #define ADDBIT 1000
  24. #define REMBIT 1001
  25. #define QUERYBIT 1002
  26. struct User {
  27.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  28.  USHORT  Slot_Number;
  29.  USHORT  Sec_Status,
  30.      Sec_Board,                   /* File or Byte Ratio */
  31.      Sec_Library,                 /* Ratio              */
  32.      Sec_Bulletin,                /* Computer Type      */
  33.      Messages_Posted;
  34.  /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  35.  ULONG   NewSinceDate, ConfRead1, ConfRead2, ConfRead3, ConfRead4,
  36.          ConfRead5;
  37.  UWORD   XferProtocol, Filler2;
  38.  UWORD   Lcfiles,BadFiles; 
  39.  ULONG   AccountDate;
  40.  UWORD   ScreenType, Filler1;
  41.  char    Conference_Access[10];
  42.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  43.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  44.  ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
  45.  char    Expert;
  46.  ULONG   ConfYM1, ConfYM2, ConfYM3, ConfYM4, ConfYM5, ConfYM6, ConfYM7,
  47.          ConfYM8, ConfYM9;
  48.  long    BeginLogCall;
  49.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  50.  };
  51.  
  52. extern VOID Register(int node);
  53. extern VOID ShutDown(VOID);
  54. VOID ClosePort(void);
  55. extern int Editfile(char Name[],int len);
  56. extern void sendmessage(char mstring[],int nl);
  57. extern void mciputstr(char mstring[],int nl);
  58. extern int Download(char *s);
  59. extern int Upload(char *s);
  60. extern void ConOnly(char mstring[],int nl);
  61. extern void SerOnly(char mstring[],int nl);
  62. extern void sendMessage(char mstring[],int nl);
  63. void MciSendStr(char mstring[],int nl);
  64. extern int GetInfo(int cmd);
  65. extern void PutInfo(int data,int cmd);
  66. extern void sendchar(char mstring[], int nl);
  67. extern void hotkey(char mstring[],char *ostring);
  68. extern int FetchKey(void);
  69. extern int sigkey(void);
  70. extern char Fhotkey(void);
  71. extern int getkey(void);
  72. extern void Chain(char *str,int node,int opt);
  73. extern void prompt(char mstring[],char *ostring,int len);
  74. extern void lineinput(char mstring[],char *ostring,int len);
  75. extern void showfile(char mstring[]);
  76. extern void showgfile(char mstring[]);
  77. extern void getuserstring(char *ostring,int nl);
  78. extern void putuserstring(char *ostring,int nl);
  79. extern int getsignal(void);
  80. extern void FlagFile(char *string);
  81. extern void CloseOut(void);
  82. extern BOOL CheckToDisplay(char *s);
  83. extern int TLock(char *str);
  84. extern APTR GetSemaphore(void);
  85. extern int AcsStat(int bits,int opt);
  86. extern void end(void);
  87. extern void LastCommand(void);
  88. extern STRPTR GetTheDate(long number);
  89. extern STRPTR GetTheTime(long number);
  90. extern void getspecdata(char *ostring,char *dest,int nl);
  91.  
  92. void getsystime(ULONG number,char *d,char *t);
  93.  
  94. struct MsgPort *port;
  95. struct MsgPort *replymp;
  96. struct JHMessage *Jhmsg,*msg;
  97. #define ANYKEY "press <RETURN> to continue"
  98. char DoorReply[] = "AEDoorRP.000";
  99. extern APTR GetSemaphore(void);
  100. VOID Register(int node)
  101. {
  102.   ULONG portsig;
  103.   int n1,n2,n3;
  104.   int found=0;
  105.   char PortName[80];
  106.   Jhmsg=(struct JHMessage *)AllocMem(sizeof(struct JHMessage),MEMF_PUBLIC);
  107.  
  108.  if(Jhmsg==0)
  109.   {
  110.      printf("Not enough Memory for message structure\n");
  111.      exit(30);
  112.   }
  113.   n1=n2=n3=0;
  114.   while(n1<10)
  115.   {
  116.     n2=0;
  117.     while(n2<10)
  118.     {
  119.       n3=0;
  120.       while(n3<10)
  121.       {
  122.         DoorReply[9]=n1+'0';
  123.         DoorReply[10]=n2+'0';
  124.         DoorReply[11]=n3+'0';
  125.         if(FindPort(DoorReply)) { n3++; continue; }
  126.         found=1; break;
  127.       }
  128.       if(found) break;
  129.       n2++;
  130.     }
  131.     if(found) break;
  132.     n1++;
  133.   }
  134.   if(!found)
  135.   {
  136.      FreeMem(Jhmsg,sizeof(struct JHMessage));
  137.     exit(30);
  138.   }
  139.   replymp=CreatePort(DoorReply,0L); strcpy(PortName,DoorReply);
  140.   
  141.  
  142.   if(replymp==0)
  143.   {
  144.     printf("Couldn't create reply port\n");
  145.     FreeMem(Jhmsg,sizeof(struct JHMessage));
  146.     exit(30);
  147.   }
  148.   Jhmsg->Msg.mn_Node.ln_Type=NT_MESSAGE;
  149.   Jhmsg->Msg.mn_Length=sizeof(struct JHMessage);
  150.   Jhmsg->Msg.mn_ReplyPort=replymp;
  151.   strcpy(Jhmsg->String,PortName);
  152.   Jhmsg->Command=JH_REGISTER;
  153.   Jhmsg->Data=2;
  154.   Jhmsg->NodeID=-1;
  155.   Jhmsg->LineNum=0;
  156.   sprintf(PortName,"AEDoorPort%d",node);
  157.   while(!(port=FindPort(PortName)));
  158.   PutMsg(port,(struct Message *)Jhmsg);
  159.  
  160.     portsig=1<<replymp->mp_SigBit;
  161.   
  162. Wait(portsig);
  163. msg=(struct JHMessage *)GetMsg((struct MsgPort *)replymp);
  164. }
  165.  
  166. VOID ShutDown(VOID)
  167. {
  168.  ULONG portsig,signal;
  169.   LastCommand();
  170.  portsig=1<<replymp->mp_SigBit;
  171.   Jhmsg->Command=JH_SHUTDOWN;
  172.   PutMsg(port,(struct Message *)Jhmsg); 
  173.   signal=Wait(portsig);
  174.   ClosePort();
  175. }
  176.  
  177. void ClosePort(void)
  178. {
  179.       while(msg=(struct JHMessage *)GetMsg((struct MsgPort *)replymp));
  180.        DeletePort((struct MsgPort *)replymp);
  181.        FreeMem(Jhmsg,sizeof(struct JHMessage));
  182. }
  183. int Editfile(char Name[],int len)
  184.          strcpy(msg->String,Name);
  185.          msg->Command=JH_EF;
  186.          msg->Data=len;
  187.          PutMsg(port,(struct Message *)Jhmsg); 
  188.          WaitPort(replymp);
  189.          GetMsg(replymp);
  190.          len=msg->Data;
  191.          if(msg->Data==-1) CloseOut();
  192.          return(len);
  193. }
  194.  
  195.  
  196. void sendmessage(char mstring[],int nl)
  197. {
  198.         register int counter;
  199.         char Temp[80];
  200.    
  201.         if(strlen(mstring)<80) sendMessage(mstring,0);
  202.         else
  203.         {
  204.           counter=0;
  205.           do
  206.           {
  207.             sprintf(Temp,"%.79s",&mstring[counter]);
  208.             sendMessage(Temp,0);
  209.             counter +=79;
  210.           }while(strlen(Temp)==79);
  211.         }
  212.         if(nl==1){ sendMessage("",1); Jhmsg->LineNum +=1; }
  213.         if(Jhmsg->LineNum==22)
  214.         { hotkey(ANYKEY,Temp); 
  215.  SM("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",0);
  216. SM("                          ",0);
  217. SM("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",0);
  218. }
  219. }
  220. void mciputstr(char mstring[],int nl)
  221. {
  222.         register int counter;
  223.         char Temp[80];
  224.    
  225.         if(strlen(mstring)<80) MciSendStr(mstring,0);
  226.         else
  227.         {
  228.           counter=0;
  229.           do
  230.           {
  231.             sprintf(Temp,"%.79s",&mstring[counter]);
  232.             MciSendStr(Temp,0);
  233.             counter +=79;
  234.           }while(strlen(Temp)==79);
  235.         }
  236.         if(nl==1) MciSendStr("",1); 
  237. }
  238. int Download(char *s)
  239. {
  240.    strcpy(Jhmsg->String,s);
  241.    Jhmsg->Command=ZMODEMSEND;
  242.    PutMsg(port,(struct Message *)Jhmsg);
  243.    WaitPort(replymp);
  244.    GetMsg(replymp);
  245.    if(Jhmsg->Data==0) return(0);
  246.    if(Jhmsg->Data==1) return(1);
  247.    if(Jhmsg->Data==-2)
  248.    {
  249.      CloseOut();
  250.    }
  251. }
  252. int BatchDownload(APTR s)
  253. {
  254.    Jhmsg->Filler1=s;
  255.    Jhmsg->Command=BATCHZMODEMSEND;
  256.    PutMsg(port,(struct Message *)Jhmsg);
  257.    WaitPort(replymp);
  258.    GetMsg(replymp);
  259.    if(Jhmsg->Data==0) return(0);
  260.    if(Jhmsg->Data==1) return(1);
  261.    if(Jhmsg->Data==-2)
  262.    {
  263.      CloseOut();
  264.    }
  265. }
  266. int Upload(char *s)
  267. {
  268.    strcpy(Jhmsg->String,s);
  269.    Jhmsg->Command=ZMODEMRECEIVE;
  270.    PutMsg(port,(struct Message *)Jhmsg);
  271.    WaitPort(replymp);
  272.    GetMsg(replymp);
  273.    if(Jhmsg->Data==0) return(0);
  274.    if(Jhmsg->Data==1) return(1);
  275.    if(Jhmsg->Data==-2)
  276.    {
  277.      CloseOut();
  278.    }
  279. }
  280. void ConOnly(char mstring[],int nl)
  281. {
  282.   Jhmsg->Data = nl;
  283.   Jhmsg->Command = JH_CO;
  284.   strcpy(Jhmsg->String,mstring);
  285.   PutMsg(port,(struct Message *)Jhmsg);
  286.   (void)WaitPort(replymp);
  287.   (void)GetMsg(replymp);
  288. }
  289. void SerOnly(char mstring[],int nl)
  290. {
  291.   Jhmsg->Data = nl;
  292.   Jhmsg->Command = JH_SO;
  293.   strcpy(Jhmsg->String,mstring);
  294.   PutMsg(port,(struct Message *)Jhmsg);
  295.   (void)WaitPort(replymp);
  296.   (void)GetMsg(replymp);
  297. }
  298. void sendMessage(char mstring[],int nl)
  299. {
  300.     Jhmsg->Data = nl;
  301.     Jhmsg->Command = JH_SM;
  302.     strcpy(Jhmsg->String,mstring);
  303.     PutMsg(port,(struct Message *)Jhmsg);
  304.     (void)WaitPort(replymp);
  305.     (void)GetMsg(replymp);
  306. }
  307. void MciSendStr(char mstring[],int nl)
  308. {
  309.     Jhmsg->Data = nl;
  310.     Jhmsg->Command = JH_MCI;
  311.     strcpy(Jhmsg->String,mstring);
  312.     PutMsg(port,(struct Message *)Jhmsg);
  313.     (void)WaitPort(replymp);
  314.     (void)GetMsg(replymp);
  315. }
  316.  
  317. int GetInfo(int cmd)
  318. {
  319.    Jhmsg->Command=cmd;
  320.    Jhmsg->Data=0;
  321.    PutMsg(port,(struct Message *)Jhmsg);
  322.    WaitPort(replymp);
  323.    GetMsg(replymp);
  324.    return(msg->Data);
  325. }
  326. void PutInfo(int data,int cmd)
  327. {
  328.    Jhmsg->Command=cmd;
  329.    Jhmsg->Data=data;
  330.    PutMsg(port,(struct Message *)Jhmsg);
  331.    WaitPort(replymp);
  332.    GetMsg(replymp);
  333. }
  334. void sendchar(char mstring[],int nl)
  335. {
  336.      char temp[3];
  337.      temp[0]=mstring[0];
  338.      temp[1]='\0';
  339.     Jhmsg->Data = nl;
  340.     Jhmsg->Command = JH_SM;
  341.      strcpy(Jhmsg->String,temp);
  342.     PutMsg(port,(struct Message *)Jhmsg);
  343.     (void)WaitPort(replymp);
  344.     (void)GetMsg(replymp);
  345. }
  346. void hotkey(char mstring[],char *ostring)
  347. {
  348.         Jhmsg->LineNum=0;
  349.     strcpy(Jhmsg->String,mstring);
  350.     Jhmsg->Command = JH_HK;
  351.     PutMsg(port,(struct Message *)Jhmsg);
  352.     (void)WaitPort(replymp);
  353.     (void)GetMsg(replymp);
  354.     strcpy(ostring,Jhmsg->String);
  355. if(Jhmsg->Data==-1) CloseOut();
  356. }
  357. int FetchKey(void)
  358. {
  359.         Jhmsg->LineNum=0;
  360.     Jhmsg->Command = JH_FETCHKEY;
  361.     PutMsg(port,(struct Message *)Jhmsg);
  362.     (void)WaitPort(replymp);
  363.     (void)GetMsg(replymp);
  364. if(Jhmsg->Data==-1) CloseOut();
  365.  return(Jhmsg->Command);
  366. }
  367. int sigkey(void)
  368. {
  369.     Jhmsg->Command = JH_ExtHK;
  370.     PutMsg(port,(struct Message *)Jhmsg);
  371.     (void)WaitPort(replymp);
  372.     (void)GetMsg(replymp);
  373.  
  374. if(Jhmsg->Data==-1) CloseOut();
  375.      return(Jhmsg->Command);
  376. }
  377. char Fhotkey(void)
  378. {
  379.         Jhmsg->LineNum=0;
  380.     Jhmsg->Command = JH_HK;
  381.     PutMsg(port,(struct Message *)Jhmsg);
  382.     (void)WaitPort(replymp);
  383.     (void)GetMsg(replymp);
  384.     
  385. if(Jhmsg->Data==-1) CloseOut();
  386.     return(*(Jhmsg->String));
  387. }
  388. int getkey(void)
  389. {
  390.         Jhmsg->LineNum=0;
  391.     Jhmsg->Command = JH_CK;
  392.     PutMsg(port,(struct Message *)Jhmsg);
  393.     (void)WaitPort(replymp);
  394.     (void)GetMsg(replymp);
  395.     if(Jhmsg->String[0]=='1') return(1); else return(0);
  396. }
  397.  
  398. void Chain(char *str,int node,int opt)
  399. {
  400.   char cmd[200];
  401.   if(opt==SHUTDOWN)
  402.   {
  403.     sprintf(cmd,"RUN >NIL: %s %d",str,node);
  404.     Jhmsg->Command=CHAIN;
  405.     PutMsg(port,(struct Message *)Jhmsg);
  406.     (void)WaitPort(replymp);
  407.     (void)GetMsg(replymp);
  408.     ClosePort();
  409.     Execute(cmd,NULL,NULL);
  410.     
  411.   }
  412.   if(opt==CHAIN_WAIT)
  413.   {
  414.     sprintf(cmd,"%s %d",str,node);
  415.     //Jhmsg->Command=CHAIN;
  416.     //PutToPort((struct Message *)Jhmsg);
  417.     //(void)WaitPort(replymp);
  418.     //(void)GetMsg(replymp);
  419.     //ClosePort();
  420.     Execute(cmd,NULL,NULL);
  421.     //Register(node);
  422.     return;
  423.   }
  424. }
  425.  
  426. void prompt(char mstring[],char *ostring,int len)
  427. {
  428.         len +=1;
  429.         Jhmsg->LineNum=0;
  430.     strcpy(Jhmsg->String,mstring);
  431.     Jhmsg->Data=len;
  432.     Jhmsg->Command = JH_PM;
  433.     PutMsg(port,(struct Message *)Jhmsg);
  434.     (void)WaitPort(replymp);
  435.     (void)GetMsg(replymp);
  436.     strcpy(ostring,Jhmsg->String);
  437. if(Jhmsg->Data==-1) CloseOut();
  438. }
  439. void AcpCommand(char mstring[],int command,int node)
  440. {
  441.      int Line;     
  442.      Line=Jhmsg->LineNum;
  443.      Jhmsg->LineNum=node;
  444.      Jhmsg->Data=command;
  445.      Jhmsg->Command=ACP_COMMAND;
  446.     PutMsg(port,(struct Message *)Jhmsg);
  447.     (void)WaitPort(replymp);
  448.     (void)GetMsg(replymp);
  449.      Jhmsg->LineNum=Line;
  450. }
  451. void lineinput(char mstring[],char *ostring,int len)
  452. {
  453.         len +=1;
  454.         Jhmsg->LineNum=0;
  455.     strcpy(Jhmsg->String,mstring);
  456.     Jhmsg->Data=len;
  457.     Jhmsg->Command = JH_LI;
  458.     PutMsg(port,(struct Message *)Jhmsg);
  459.     (void)WaitPort(replymp);
  460.     (void)GetMsg(replymp);
  461.     strcpy(ostring,Jhmsg->String);
  462. if(Jhmsg->Data==-1) CloseOut();
  463. }
  464. void showfile(char mstring[])
  465. {
  466.     strcpy(Jhmsg->String,mstring);
  467.     Jhmsg->Command = JH_SF;
  468.     PutMsg(port,(struct Message *)Jhmsg);
  469.     (void)WaitPort(replymp);
  470.     (void)GetMsg(replymp);
  471. }
  472. void showgfile(char mstring[])
  473. {
  474.     strcpy(Jhmsg->String,mstring);
  475.     Jhmsg->Command = JH_SG;
  476.     PutMsg(port,(struct Message *)Jhmsg);
  477.     (void)WaitPort(replymp);
  478.     (void)GetMsg(replymp);
  479. }
  480.  
  481. void getuserstring(char *ostring,int nl)
  482. {
  483.         Jhmsg->Command = nl;
  484.         Jhmsg->Data=READIT;
  485.     PutMsg(port,(struct Message *)Jhmsg);
  486.     (void)WaitPort(replymp);
  487.     (void)GetMsg(replymp);
  488.    strcpy(ostring,Jhmsg->String);
  489. }
  490. void putuserstring(char *ostring,int nl)
  491. {
  492.         Jhmsg->Command = nl;
  493.         Jhmsg->Data=WRITEIT;
  494.         strcpy(Jhmsg->String,ostring);
  495.     PutMsg(port,(struct Message *)Jhmsg);
  496.     (void)WaitPort(replymp);
  497.     (void)GetMsg(replymp);
  498.  
  499. }
  500. void getspecdata(char *ostring,char *dest,int nl);
  501. void getspecdata(char *ostring,char *dest,int nl)
  502. {
  503.         Jhmsg->Command = nl;
  504.         Jhmsg->Data=WRITEIT;
  505.         strcpy(Jhmsg->String,ostring);
  506.     PutMsg(port,(struct Message *)Jhmsg);
  507.     (void)WaitPort(replymp);
  508.     (void)GetMsg(replymp);
  509.      strcpy(dest,Jhmsg->String);
  510.  
  511. }
  512. /*
  513. struct MsgPort *CreatePort(UBYTE *name,LONG pri)
  514. {
  515.   int sigBit;
  516.   struct MsgPort *mp;
  517.   
  518.   if((sigBit=AllocSignal(-1L))==-1)
  519.     return(NULL);
  520.   mp=(struct MsgPort *)
  521.      AllocMem((ULONG)sizeof(struct MsgPort),(ULONG)MEMF_CLEAR|MEMF_PUBLIC);
  522.   if(!mp)
  523.   {
  524.     FreeSignal(sigBit);
  525.     return(NULL);
  526.   }
  527.   mp->mp_Node.ln_Name=name;
  528.   mp->mp_Node.ln_Pri=pri;
  529.   mp->mp_Node.ln_Type=NT_MSGPORT;
  530.   mp->mp_Flags=PA_SIGNAL;
  531.   mp->mp_SigBit=sigBit;
  532.   mp->mp_SigTask=(struct Task *)FindTask(0L);
  533.   if(name)
  534.     AddPort(mp);
  535.   else
  536.     NewList(&(mp->mp_MsgList));
  537.   return(mp);
  538. }
  539. */
  540. int getsignal(void)
  541. {
  542.   Jhmsg->Command = JH_SIGBIT;
  543.     PutMsg(port,(struct Message *)Jhmsg);
  544.     (void)WaitPort(replymp);
  545.     (void)GetMsg(replymp);
  546.    return(Jhmsg->Data);
  547. }
  548. void FlagFile(char *string)
  549. {
  550.    strcpy(Jhmsg->String,string);
  551.     Jhmsg->Command = JH_FLAGFILE;
  552.     PutMsg(port,(struct Message *)Jhmsg);
  553.     (void)WaitPort(replymp);
  554.     (void)GetMsg(replymp);
  555. }
  556. VOID CloseOut(void)
  557. {
  558.   ShutDown();
  559.   end();
  560. }
  561. BOOL CheckToDisplay(char *s)
  562. {
  563. register int loop;
  564. char FileName[200];
  565. char temp[200];
  566. getuserstring(FileName,DT_SECSTATUS);
  567. loop=atoi(FileName);
  568. strcpy(FileName,s);
  569.     loop=(loop-(loop%5));
  570.     for(; loop>2; loop-=5)
  571.         {
  572.         sprintf(temp,"%s%d.txt",FileName,loop);
  573.           if(TLock(temp))
  574.           {
  575.             sprintf(temp,"%s%d",FileName,loop);
  576.             showgfile(temp); return(1);
  577.           }
  578.           sprintf(temp,"%s%d.txt.gr",FileName,loop);
  579.           if(TLock(temp))
  580.           {
  581.              sprintf(temp,"%s%d",FileName,loop);
  582.              showgfile(temp); return(1);
  583.           }
  584.           sprintf(temp,"%s%d.GR1",FileName,loop);
  585.           if(TLock(temp))
  586.           {
  587.              sprintf(temp,"%s%d",FileName,loop);
  588.              showgfile(temp); return(1);
  589.           }          
  590.     }
  591.      sprintf(temp,"%s.txt",FileName);
  592.      if(TLock(temp))
  593.      {
  594.        showgfile(FileName); return(1);
  595.      }
  596.      sprintf(temp,"%s.txt.gr",FileName);
  597.      if(TLock(temp))
  598.      {
  599.        showgfile(FileName); return(1);
  600.      }
  601.      sprintf(temp,"%s.GR1",FileName);
  602.      if(TLock(temp))
  603.      {
  604.        showgfile(FileName); return(1);
  605.      }
  606.      return(0);
  607. }
  608.  
  609. int TLock(char *str)
  610. {
  611.   long lock;
  612.   if(lock=Lock(str,ACCESS_READ))
  613.   {
  614.     UnLock(lock); return(1);
  615.   }
  616.   return(0);
  617. }
  618. APTR GetSemaphore(void)
  619. {
  620.    Jhmsg->Command=MULTICOM;
  621.    PutMsg(port,(struct Message *)Jhmsg);
  622.     (void)WaitPort(replymp);
  623.     (void)GetMsg(replymp);
  624.      return(msg->Semi);
  625. }
  626. int AcsStat(int bits,int opt)
  627. {
  628.    switch(opt)
  629.    {
  630.      case ADDBIT:
  631.           Jhmsg->Command=ADDBIT;
  632.           Jhmsg->Data=bits;
  633.           break;
  634.      case REMBIT:
  635.           Jhmsg->Command=REMBIT;
  636.           Jhmsg->Data=bits;
  637.           break;
  638.      case QUERYBIT:
  639.           Jhmsg->Command=QUERYBIT;
  640.           Jhmsg->Data=bits;
  641.           break;
  642.      default: return(0);
  643.    } 
  644.        PutMsg(port,(struct Message *)Jhmsg);
  645.     (void)WaitPort(replymp);
  646.     (void)GetMsg(replymp);
  647.      return(msg->Command);
  648. }
  649. STRPTR GetTheDate(long number)
  650. {
  651.   char Date[22];
  652.   getsystime(number,Date,NULL);
  653.   return(Date);
  654. }
  655. STRPTR GetTheTime(long number)
  656. {
  657.   char temp[30];
  658.   getsystime(number,NULL,temp);
  659.  return(temp);
  660. }
  661. void DateToString(ULONG number,char *s)
  662. {
  663.   char Date[22];
  664.   getsystime(number,Date,NULL);
  665.   strcpy(s,Date);
  666. }
  667. void TimeToString(ULONG number,char *s)
  668. {
  669.   char temp[30];
  670.   getsystime(number,NULL,temp);
  671.   strcpy(s,temp);
  672. }
  673. ULONG UnixTimeOffset = 252482400;
  674.  
  675. /**********************************************************
  676.  *    ULONG getsystime(struct timeval *tv)
  677.  *
  678.  *      This function was rewritten using DateStamp() to
  679.  * eliminate the opening and closing of the timer.device
  680.  * that was occurring everytime this function was called.
  681.  * An attempt to save some processing time.   -WMP-
  682.  **********************************************************/
  683. void getsystime(ULONG number,char *d,char *t)
  684. {
  685.   struct DateStamp ds;
  686.    struct DateTime dt;
  687.    if(number==0L)
  688.    {
  689.      DateStamp(&ds);
  690.      dt.dat_Stamp=ds;
  691.    }
  692.    else
  693.    {
  694.       number -= UnixTimeOffset;
  695.       dt.dat_Stamp.ds_Days=number/(60L*60L*24L);
  696.                            number -= dt.dat_Stamp.ds_Days*(60L*60L*24L);
  697.       dt.dat_Stamp.ds_Minute=number/60L; 
  698.       dt.dat_Stamp.ds_Tick=0L;
  699.    }
  700.      dt.dat_Format=FORMAT_USA;
  701.    dt.dat_StrDay=NULL;
  702.    dt.dat_StrDate=d;
  703.    dt.dat_StrTime=t;
  704.    dt.dat_Flags=DTB_SUBST;
  705.    DateToStr(&dt);
  706. }
  707.  
  708. int Load_Account(int UserNum,APTR u,APTR uk)
  709. {
  710.     Jhmsg->Command = LOAD_ACCOUNT;
  711.      Jhmsg->Data=UserNum;
  712.      Jhmsg->Filler1=u;
  713.      Jhmsg->Filler2=uk;
  714.     PutMsg(port,(struct Message *)Jhmsg);
  715.     (void)WaitPort(replymp);
  716.     (void)GetMsg(replymp);
  717.      return(Jhmsg->Data);
  718. }
  719. int Search_Account(int UserNum,APTR uk)
  720. {
  721.     Jhmsg->Command = SEARCH_ACCOUNT;
  722.      Jhmsg->Data=UserNum;
  723.      Jhmsg->Filler1=uk;
  724.     PutMsg(port,(struct Message *)Jhmsg);
  725.     (void)WaitPort(replymp);
  726.     (void)GetMsg(replymp);
  727.      return(Jhmsg->Data);
  728. }
  729. void Save_Account(int UserNum,APTR u,APTR uk)
  730. {
  731.     Jhmsg->Command = SAVE_ACCOUNT;
  732.      Jhmsg->Data=UserNum;
  733.      Jhmsg->Filler1=u;
  734.      Jhmsg->Filler2=uk;
  735.     PutMsg(port,(struct Message *)Jhmsg);
  736.     (void)WaitPort(replymp);
  737.     (void)GetMsg(replymp);
  738. }
  739.  
  740. void Save_ConfDB(int UserNum,int conf,APTR dat)
  741. {
  742.      Jhmsg->Command = SAVE_CONFDB;
  743.      Jhmsg->Data=UserNum;
  744.      Jhmsg->NodeID=conf;
  745.      Jhmsg->Filler1=dat;
  746.     PutMsg(port,(struct Message *)Jhmsg);
  747.     (void)WaitPort(replymp);
  748.     (void)GetMsg(replymp);
  749. }
  750. void New_Account(APTR u,APTR uk)
  751. {
  752.      Jhmsg->Command = APPEND_ACCOUNT;
  753.      Jhmsg->Filler1=u;
  754.      Jhmsg->Filler2=uk;
  755.     PutMsg(port,(struct Message *)Jhmsg);
  756.     (void)WaitPort(replymp);
  757.     (void)GetMsg(replymp);
  758. }
  759. void Load_ConfDB(int UserNum,int conf,APTR dat)
  760. {
  761.      Jhmsg->Command = LOAD_CONFDB;
  762.      Jhmsg->Data=UserNum;
  763.      Jhmsg->NodeID=conf;
  764.      Jhmsg->Filler1=dat;
  765.     PutMsg(port,(struct Message *)Jhmsg);
  766.     (void)WaitPort(replymp);
  767.     (void)GetMsg(replymp);
  768. }
  769.  
  770.  
  771. int Get_ConfName(APTR n,APTR l,int num)
  772. {
  773.      char *s;
  774.      strcpy((char *)n,"");
  775.      Jhmsg->Command = GET_CONFNUM;
  776.      Jhmsg->Data=num;
  777.      Jhmsg->Filler1=n;
  778.      Jhmsg->Filler2=l;
  779.     PutMsg(port,(struct Message *)Jhmsg);
  780.     (void)WaitPort(replymp);
  781.     (void)GetMsg(replymp);
  782.      s=(char *)n;
  783.      if(*s=='\0') return(0);
  784.      return(1);
  785. }
  786. int IsAccess(int acs)
  787. {
  788.      Jhmsg->Command = DT_QUERYBIT;
  789.      Jhmsg->Data=acs;
  790.     PutMsg(port,(struct Message *)Jhmsg);
  791.     (void)WaitPort(replymp);
  792.     (void)GetMsg(replymp);
  793.      return(Jhmsg->Command);
  794. }
  795. void GetFiller1(APTR Filler,int Command)
  796. {
  797.      Jhmsg->Command=Command;
  798.      Jhmsg->Data=0;
  799.      Jhmsg->Filler1=Filler;
  800.      PutMsg(port,(struct Message *)Jhmsg);
  801.      WaitPort(replymp);
  802.      GetMsg(replymp);
  803. }
  804. void PutFiller1(APTR Filler,int Command)
  805. {
  806.      Jhmsg->Command=Command;
  807.      Jhmsg->Data=1;
  808.      Jhmsg->Filler1=Filler;
  809.      PutMsg(port,(struct Message *)Jhmsg);
  810.      WaitPort(replymp);
  811.      GetMsg(replymp);
  812. }